package com.stox.charting.ui.swing.scheme.color;

import java.awt.Color;
import java.util.List;

import com.stox.charting.ui.swing.model.ChartModel;
import com.stox.charting.ui.swing.model.uiUnit.AbstractUiUnit;
import com.stox.core.model.IBar;


public class DefaultColorScheme<T extends IBar> implements ColorScheme<T> {
	
	@SuppressWarnings("unchecked")
	public Color getColor(ChartModel<T> chartModel, int index){
		List<? extends AbstractUiUnit<IBar>> uiUnits = (List<? extends AbstractUiUnit<IBar>>)chartModel.getViewport().getUiUnits();
		if(uiUnits != null && uiUnits.size() > (index + 1)){
			if(uiUnits.get(index).getValue().getClose() >  uiUnits.get(index + 1).getValue().getClose()){
				return Color.GREEN;
			}
		}
		return Color.RED;
	}
	

}
